package com.markerhub.controller;

import com.markerhub.common.lang.Result;
import com.markerhub.handler.Wx_Token_Auth;
import com.markerhub.service.ISmsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author by MaXiaofeng
 * @Description 短信业务controller
 * @Date 2022/2/13 18:04
 * @Version 1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/sms")
public class SmsController {
    @Autowired
    private ISmsService smsService;

    /**
     * 关闭柜门后，点击发送短信功能，系统自动向外卖下单手机号码发送短信
     * （短信内容应包括取餐码，外卖柜号，且提示若存餐满12h未取将被清除）
     *
     * @param jsonBody
     * @return
     */
    @Wx_Token_Auth
    @PostMapping("/takeFood")
    public Result sendMsgToTakeFood(@RequestBody Map<String, String> jsonBody) {
        String phone = jsonBody.get("phone");
        int cabinet_doorNum = Integer.parseInt(jsonBody.get("cabinet_doorNum"));
        Result result = smsService.sendSmsByCabinetNum(phone,cabinet_doorNum);
        //绑定日志
        log.info("{}", result);
        return result;
    }

}
